package com.charmzenus.smallshop.service.impl;

import com.charmzenus.smallshop.bean.UserBean;
import com.charmzenus.smallshop.repository.UserRepository;
import com.charmzenus.smallshop.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class UserServiceImpl implements IUserService {

    @Autowired
    UserRepository userRepository;

    public UserBean test() {
        return userRepository.getOne(30);
    }
//    public UserBean test() {
//        return userRepository.findById(30);
//    }

    @Transactional
    public void addUser() {
        UserBean userBean = new UserBean("TestName",
                "$2y$10$jQAkySdYLY0R1/HCNNEdaePaQdm5tzU3WmuDdFImy5PPsRCTSt86C",
                "3349005169@qq.com","13169592703","TestName Xiao", 1, 0, "http://m.xmonv.cn/public/res/images/ucenter/index/noPortrait_Female.png",
                "这个人很懒， 什么都没留下", "","", "0",1524454852, 1524454852);

        userRepository.save(userBean);
        if(userBean != null) throw new RuntimeException();
    }
}
